﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.CodeDom.Compiler;
using Microsoft.CSharp;

namespace MedicalSystems
{
    public static class Globals
    {
        public static List<Record> dataSet;
        public static List<DerivedRecord> derived;

        //public bool init = false;
        private static DateTime initTime = DateTime.Now;

        public static void setTxnFinish()
        {
            foreach (Record rec in Globals.dataSet)
            {
                List<Record> newer = new List<Record>();
                newer = (from r in Globals.dataSet
                         where ((r.txnStartTime > rec.txnStartTime) ||
                                (r.txnStartTime == rec.txnStartTime && r.startTime > rec.startTime) ||
                                (r.txnStartTime == rec.txnStartTime && r.startTime == rec.startTime && r.finishTime > rec.finishTime))
                         && r.FullName == rec.FullName
                         && r.Parameter == rec.Parameter
                         orderby r.txnStartTime
                         select r).ToList();
                if (newer.Count > 0)
                {
                    //rec.txnFinishTime = newer[0].txnStartTime;
                    rec.setValueByIndex(newer[0].txnStartTime.ToString(), 8);
                }
            }
        }

        public static DateTime CURRENT_DATE
        {
            get
            {
                return Convert.ToDateTime("12/10/1999").AddTicks(DateTime.Now.Ticks - initTime.Ticks);
            }
        }
    }
}
